package com.fwh.gmall.base;

public class Result {
    private int code;
    private String msg;
    private Object data;

    // 构造方法
    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    // 成功（无数据）
    public static Result success() {
        return new Result(200, "成功", null);
    }

    // 成功（有数据）
    public static Result success(Object data) {
        return new Result(200, "成功", data);
    }

    // 失败
    public static Result error(int code, String msg) {
        return new Result(code, msg, null);
    }

    // Getter 和 Setter
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}